package com.zzyl.mapper;

import com.zzyl.entity.NursingPlan;
import com.zzyl.entity.NursingProjectPlan;
import com.zzyl.vo.NursingProjectPlanVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NursingProjectPlanMapper {

    /**
     * 批量向中间表写入数据
     * @param projectPlans
     */
    void insertBatch(List<NursingProjectPlan> projectPlans);

    /**
     * 根据Id查询 单表查询project_plan中间表缺少projectName 所以需要两张表查询并且封装到Vo
     * @param id
     * @return
     */
    @Select("select pp.*,np.name projectName from nursing_project_plan pp left join nursing_project np on pp.project_id = np.id where plan_id =#{id}")
    List<NursingProjectPlanVo> getById(Integer id);

    /**
     * 根据Id删除中间表的数据
     * @param id
     */
    @Delete("delete from nursing_project_plan where id = #{id}")
    void delById(Integer id);
}
